fix(inference): unpack structured records per sample, not all-or-nothing - #1669
Open
Anai-Guo wants to merge 1 commit into
Open
fix(inference): unpack structured records per sample, not all-or-nothing#1669Anai-Guo wants to merge 1 commit into
Anai-Guo wants to merge 1 commit into
Conversation
infer_data_job() only splits the prediction / extra_records columns when
EVERY sample is a structured record:
if all(_is_structured_record(data_all[x]) for x in data['index']):
But a sample that exhausts its retries comes back from BaseAPI.generate as
a plain string (`return self.fail_msg if answer in ['', None] else answer`),
while a successful one returns {"prediction": ..., "extra_records": ...}.
A single failed sample therefore makes all(...) False, and every successful
record in the run is stringified into its own dict repr - the extra_records
column is never created, and the prediction column holds
"{'prediction': ..., 'extra_records': {...}}" for downstream scoring.
Unpack each sample on its own via a shared helper, and gate on any(...) so
that a run with no structured records at all still takes the old path.
Fully homogeneous runs (all structured, none structured) are unchanged.
The SPLIT_THINK branch had the same all-or-nothing gate and is fixed too;
there the corruption is worse, because split_thinking() then cuts the dict
repr at '</think>' and leaves the tail glued to the answer.
Fixes open-compass#1665
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1665.
The bug
infer_data_job()splits the structured return shape intoprediction/extra_recordscolumns only if every sample is structured:A failed sample can never satisfy that predicate.
BaseAPI.generatereturnsthe structured dict only on the success path, and falls through to a plain
string once retries are exhausted:
So one transient API failure anywhere in the run flips
all(...)toFalseand every successful structured record is passed through
str().vlmeval/api/arm_thinker.pyis a shipped model class that hits this.The fix
Unpack per sample through a shared helper, and gate on
any(...). A failedrow keeps its
fail_msgstring inprediction(so failure accounting andretry_failedare unaffected) and gets{}inextra_records.The
SPLIT_THINKbranch had the identical gate and is fixed the same way.Verification
verify.pylifts the real rank-0 assembly block out ofvlmeval/inference.pywith
ast(node.lineno..end_lineno, thendedent) from both themainversion and the patched version, so nothing is hand-copied, and replays it
over a 3-sample run where sample 2 exhausted its retries.
Mixed run — the reported case:
Regression guard — homogeneous runs must not move:
pre-commit's flake8 (7.1.2,--max-line-length=120 --ignore=W503) reportsthe same findings before and after, none of them on an added line; isort 6.0.1
is clean.
🤖 Generated with Claude Code